<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Responsive Admin Dashboard Template">
    <meta name="keywords" content="admin,dashboard">
    <meta name="author" content="skcats">
    <!-- The above 6 meta tags *must* come first in the head; any other head content must come *after* these tags -->

    <!-- Title -->
    <title>{{ constant('App\\Lib\\Constant\\Tool::PROJECT_NAME') }}</title>

    <!-- Styles -->
    <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
    <link href="{{ asset('assets/plugins/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/plugins/font-awesome/css/font-awesome.min.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/plugins/icomoon/style.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/plugins/uniform/css/default.css') }}" rel="stylesheet"/>
    <link href="{{ asset('assets/plugins/switchery/switchery.min.css') }}" rel="stylesheet"/>

    <!-- Theme Styles -->
    <link href="{{ asset('assets/css/ecaps.min.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/css/custom.css') }}" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<!-- Page Container -->
<div class="page-container">
    <!-- Page Inner -->
    <div class="page-inner login-page">
        <div id="main-wrapper" class="container-fluid">
            <div class="row">
                <div class="col-sm-6 col-md-3 login-box">
                    <h4 class="login-title">{{ constant('App\\Lib\\Constant\\Tool::PROJECT_NAME') }}</h4>
                    <form action="{{ path(constant_route('LOGIN_SUBMIT')) }}" method="post">
                        <div class="form-group">
                            <label for="username">用户名</label>
                            <input type="text" class="form-control" id="username" autofocus required>
                        </div>
                        <div class="form-group">
                            <label for="password">密码</label>
                            <input type="password" class="form-control" id="password" required>
                        </div>
                        <button type="button" class="btn btn-primary" id="login">登录</button>
                    </form>
                </div>
            </div>
        </div>
    </div><!-- /Page Content -->
</div><!-- /Page Container -->

<input type="hidden" name="csrf-token" value="{{ csrf_token(constant('App\\Lib\\Constant\\Tool::CSRF_NAME')) }}"/>

<!-- Javascripts -->
<script src="{{ asset('assets/plugins/jquery/jquery-3.1.0.min.js') }}"></script>
<script src="{{ asset('assets/plugins/bootstrap/js/bootstrap.min.js') }}"></script>
<script src="{{ asset('assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js') }}"></script>
<script src="{{ asset('assets/plugins/uniform/js/jquery.uniform.standalone.js') }}"></script>
<script src="{{ asset('assets/plugins/switchery/switchery.min.js') }}"></script>
<script src="{{ asset('assets/js/ecaps.js') }}"></script>
<script src="{{ asset('assets/js/layer/layer.js') }}"></script>
<!-- 工具函数 -->
<script src="{{ asset('assets/js/tool.js') }}"></script>
<script src="{{ asset('assets/js/logic/action.js') }}"></script>
<script type="text/javascript">
    $(function () {
        function loginSubmit(){
            let url = '{{ path(constant_route('LOGIN_SUBMIT')) }}';
            let username = $('#username').val().trim();
            let password = $('#password').val().trim();
            if (username === '') {
                layer.msg('请输入用户名', {time: 1500});
                $('#username').focus();
                return false;
            }
            if (password === '') {
                layer.msg('请输入密码', {time: 1500});
                $('#username').focus();
                return false;
            }
            Tools.ajax({
                url,
                data: {username, password},
                success: function (data) {
                    layer.msg(data.msg, {time: 1500}, function () {
                        if (data.status) {
                            window.location.href = '{{ path(constant_route('HOME')) }}';
                        }
                    })
                }
            })
        }
        $(document).keydown(function(e){
            if(e.keyCode === 13){
                loginSubmit();
            }
        })
        $('#login').click(loginSubmit);
    });
</script>
</body>
</html>